package ThreadCreat;

import java.security.PublicKey;

/**
 * ClassName ThreadCreat.Thread01
 * Description TODO
 * Author Hexiao
 * Date 2018/8/24 10:06
 * Version 1.0
 **/
public class Thread01 {
    public static void main(String[] args) throws InterruptedException {
//        使用Runnable方式创建线程
//     ThreadCreat.ThreadRunnable threadRunnable=new ThreadCreat.ThreadRunnable();
////     Thread thread=new Thread(threadRunnable);
////     thread.run();
        Thread thread=new Thread(){
            @Override
            public void run() {
                System.out.println("ThreadCreat.Thread01 thread run.........");
                //线程创建后
                System.out.println("run="+getState());//线程创建后的状态RUNNABLE
                System.out.println("run="+isAlive());//判断当前的线程是否处于活动状态true
            }
        };
        //线程正在执行时
        System.out.println("thread.getState="+thread.getState());//NEW
        System.out.println("thread.isAlive="+thread.isAlive());//false
        thread.start();

        Thread.sleep(1000);
        //线程结束后
        System.out.println("thread.getState="+thread.getState());//TERMINATED
        System.out.println("thread.isAlive="+thread.isAlive());//false

    }

    }
